package com.jie.component.lock.factory;

import com.jie.component.lock.core.LockType;
import com.jie.component.lock.core.ManageLocker;
import com.jie.component.lock.locker.ServiceLocker;
import lombok.AllArgsConstructor;

@AllArgsConstructor
public class ServiceLockFactory {

    private final ManageLocker manageLocker;

    public ServiceLocker getLock(LockType lockType) {
        return switch (lockType) {
            case Fair -> manageLocker.getFairLocker();
            case Write -> manageLocker.getWriteLocker();
            case Read -> manageLocker.getReadLocker();
            default -> manageLocker.getReentrantLocker();
        };
    }
}